package cn.wtg.kotlindemo.testDatabinding

import android.view.View
import androidx.databinding.ObservableInt
import cn.wtg.kotlindemo.R
import cn.wtg.kotlinlib.baseUi.BaseActivity
import cn.wtg.kotlinlib.baseViewModel.BaseActivityLifecycleVM

/**
 * author: wtg
 * time: 2022/12/15
 * desc:
 */
class TestDataBindVM(mActivity: BaseActivity) : BaseActivityLifecycleVM(mActivity) {
    var textColor = ObservableInt(R.color.teal_700)
    var textBackgroundColorResId = ObservableInt(R.color.teal_700)
    var textBackgroundDrawableResId = ObservableInt(R.drawable.rect_ff018786_r10)

    override fun initView() {

    }

    override fun onViewClick(view: View?) {
        if (view != null) {
            when(view.id){
                R.id.tv1->{textColor.set(R.color.teal_200)}
                R.id.tv2->{textBackgroundDrawableResId.set(R.drawable.rect_ff03dac5_r10)}
                R.id.tv3->{textBackgroundColorResId.set(R.color.teal_200)}
            }
        }
    }
}